package com.lovetemperature.service.impl;

import java.util.List;

import com.lovetemperature.dao.Dao;
import com.lovetemperature.model.Order;
import com.lovetemperature.model.Shop;
import com.lovetemperature.service.ShopService;

public class ShopServiceImpl implements ShopService{
	private Dao<Shop> shopDao;

	@Override
	public List<Shop> findAllShop() {
		return shopDao.findAll();
	}

	public Dao<Shop> getShopDao() {
		return shopDao;
	}

	public void setShopDao(Dao<Shop> shopDAO) {
		this.shopDao = shopDAO;
	}

	@Override
	public List<Order> findAllOrder(Long shopId) {
		return shopDao.findById(shopId).getNonFinishedOrders();
	}

	@Override
	public void update(Shop shop) {
		shopDao.update(shop);
	}

	@Override
	public Shop findById(Long id) {
		return shopDao.findById(id);
	}

	@Override
	public void addShop(Shop shop) {
		shopDao.save(shop);
	}

	@Override
	public void delect(Long shopId) {
		Shop shop = shopDao.findById(shopId);
		if(shop!=null && shop.getShopId()!=0){
			shopDao.delect(shop);
		}
	}

}
